VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "DAOEmpleado"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private mvarConnection As utilConexion
Public Property Set Connection(ByVal vData As utilConexion)
    Set mvarConnection = vData
End Property
'---------------------------------------------------------------------------------------
' Procedure : getLista
' DateTime  : 23/06/2008 18:02
' Author    :
' Purpose   :
'---------------------------------------------------------------------------------------

Public Function getListaxCodigo(bean As bEmpleado) As Collection
'On Error GoTo hnderr
Dim sql As String
Dim rst As New Recordset
Dim list As New Collection
Dim record As bEmpleado
sql = "SELECT ncodigo ,snombres , sapellidos, snomcorto, nestado , sdescripcion, sCodBarra, spassword "
sql = sql + "FROM proc_empleado_lista(" + CStr(bean.bestado.nCodigo) + ");"
rst.Open sql, mvarConnection.Connection, adOpenForwardOnly
While Not rst.EOF
    Set record = New bEmpleado
    If Not IsNull(rst.Fields("ncodigo")) Then record.nCodigo = rst.Fields("ncodigo").value
    If Not IsNull(rst.Fields("snombres")) Then record.sNombres = rst.Fields("snombres").value
    If Not IsNull(rst.Fields("sapellidos")) Then record.sApellidos = rst.Fields("sapellidos").value
    If Not IsNull(rst.Fields("snomcorto")) Then record.sNombreCorto = rst.Fields("snomcorto").value
    If Not IsNull(rst.Fields("nestado")) Then record.bestado.nCodigo = rst.Fields("nestado").value
    If Not IsNull(rst.Fields("sdescripcion")) Then record.bestado.sdescripcion = rst.Fields("sdescripcion").value
    If Not IsNull(rst.Fields("sCodBarra")) Then record.sCodBarra = rst.Fields("sCodBarra").value
    If Not IsNull(rst.Fields("spassword")) Then record.Password = rst.Fields("spassword").value
    rst.MoveNext
    list.Add record
Wend
Set getListaxCodigo = list
hnderr:
If Err.Number = 0 Then Exit Function
cloneError Err
End Function
Public Function getListaxCodigoBarra(bean As bEmpleado) As Collection
'On Error GoTo hnderr
Dim sql As String
Dim rst As New Recordset
Dim list As New Collection
Dim record As bEmpleado
sql = "SELECT ncodigo ,snombres , sapellidos, snomcorto, nestado , sdescripcion, scodBarra, spassword "
sql = sql + "FROM proc_empleado_lista('" + CStr(bean.sCodBarra) + "');"
rst.Open sql, mvarConnection.Connection, adOpenForwardOnly
While Not rst.EOF
    Set record = New bEmpleado
    If Not IsNull(rst.Fields("ncodigo")) Then record.nCodigo = rst.Fields("ncodigo").value
    If Not IsNull(rst.Fields("snombres")) Then record.sNombres = rst.Fields("snombres").value
    If Not IsNull(rst.Fields("sapellidos")) Then record.sApellidos = rst.Fields("sapellidos").value
    If Not IsNull(rst.Fields("snomcorto")) Then record.sNombreCorto = rst.Fields("snomcorto").value
    If Not IsNull(rst.Fields("nestado")) Then record.bestado.nCodigo = rst.Fields("nestado").value
    If Not IsNull(rst.Fields("sdescripcion")) Then record.bestado.sdescripcion = rst.Fields("sdescripcion").value
    If Not IsNull(rst.Fields("sCodBarra")) Then record.sCodBarra = rst.Fields("sCodBarra").value
    If Not IsNull(rst.Fields("spassword")) Then record.Password = rst.Fields("spassword").value
    rst.MoveNext
    list.Add record
Wend
Set getListaxCodigoBarra = list
hnderr:
If Err.Number = 0 Then Exit Function
cloneError Err
End Function
'---------------------------------------------------------------------------------------
' Procedure : guardarNuevo
' DateTime  : 23/06/2008 18:02
' Author    :
' Purpose   :
'---------------------------------------------------------------------------------------
'
Public Function guardarNuevo(bean As bEmpleado) As Integer
On Error GoTo hnderr
Dim rst As Recordset
Dim sql As String
sql = "select * from proc_empleado_inserta('" + bean.sNombres + "','"
sql = sql + bean.sApellidos + "','" + bean.sNombreCorto + "'," + CStr(bean.bestado.nCodigo) + ",'"
sql = sql + bean.Password + "')"
Set rst = mvarConnection.Connection.Execute(sql)
guardarNuevo = UtilConstantes.OPT_DATOS_GUARDADOS
hnderr:
If Err.Number = 0 Then Exit Function
guardarNuevo = UtilConstantes.OPT_ERROR_ENCONTRADO
cloneError Err
Err.Clear
End Function
'---------------------------------------------------------------------------------------
' Procedure : actualizar
' DateTime  : 23/06/2008 18:02
' Author    :
' Purpose   :
'---------------------------------------------------------------------------------------
'
Public Function actualizar(bean As bEmpleado) As Integer
On Error GoTo hnderr
Dim sql As String
sql = "select * from proc_empleado_actualiza('" + bean.sNombres + "','"
sql = sql + bean.sApellidos + "','" + bean.sNombreCorto + "'," + CStr(bean.bestado.nCodigo) + ",'"
sql = sql + bean.sCodBarra + "','" + bean.Password + "'," + CStr(bean.nCodigo) + ")"
mvarConnection.Connection.Execute sql
actualizar = UtilConstantes.OPT_DATOS_GUARDADOS
hnderr:
If Err.Number = 0 Then Exit Function
actualizar = UtilConstantes.OPT_ERROR_ENCONTRADO
cloneError Err
Err.Clear
End Function
